package com.sk.bilibili.model.fragment.main.shop;

import com.sk.api.annotations.Autowired;
import com.sk.bilibili.bean.Goods;
import com.sk.bilibili.callBack.RequestCallBack;
import com.sk.bilibili.dto.Page;
import com.sk.bilibili.mapper.GoodsMapper;
import com.sk.bilibili.model.BaseRefreshModel;
import com.sk.bilibili.utils.RequestUtils;
import com.sk.bilibili.view.fragment.main.home.shop.GoodsFragment;

public class GoodsModel extends BaseRefreshModel<GoodsFragment> {

    @Autowired
    GoodsMapper goodsMapper;
    private int page=1;

    public void loadData(boolean magic) {
        RequestUtils.process(goodsMapper.page(page, magic), goodsPage -> {
            page++;
            view.loadDataSuccess(goodsPage.getRecords());
        });
    }

    public void refreshData(boolean magic) {
        page=1;
        RequestUtils.process(goodsMapper.page(page, magic), goodsPage -> {
            page++;
            view.refreshDataSuccess(goodsPage.getRecords());
        });
    }

}